package com.sporadic.desk.controller;

import com.sporadic.desk.pojo.Dishes;
import com.sporadic.desk.service.DishesService;
import dto.DishesDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import vo.ResponseData;

import java.util.List;

/**
 * @program: sporadic
 * @description:
 * @author: LHD   QQ:1727865856
 * @create: 2019-10-22 09:01
 **/
@RestController
@CrossOrigin(value = "http://localhost:8080")
public class DishesController {
    @Autowired
    private DishesService dishesService;

    @GetMapping("/queryDishes")
    public ResponseData<List<DishesDTO>> queryDishes(Integer mid, Integer menuid) {
        List<DishesDTO> dishes = dishesService.queryDishes(mid, menuid);
        return dishes.isEmpty() ? new ResponseData<>(null, "商品为空") : new ResponseData<>(dishes);
    }

    @GetMapping("/querybyOrderId")
    public ResponseData<List<DishesDTO>> selectByOrderIdDis(String orderId) {
        List<DishesDTO> dishesDTOS = dishesService.selectByorderId(orderId);
        return dishesDTOS.isEmpty() ? new ResponseData<>(null, "订单信息为空") : new ResponseData<>(dishesDTOS);
    }
}
